home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 605 < prev    next >
Internet Message Format  |  1996-08-06  |  1KB

  1. Path: solon.com!not-for-mail
  2. From: stanr@tiac.net (Stan Ryckman)
  3. Newsgroups: comp.lang.c.moderated,comp.std.c
  4. Subject: Re: 'h' modifier in printf
  5. Date: 19 Mar 1996 06:47:16 -0600
  6. Organization: Amber & Sneakers Fan Club
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4imack$duv@solutions.solon.com>
  10. References: <4i801c$455@solutions.solon.com> <4i98fl$8ml@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4i98fl$8ml@solutions.solon.com>,
  14.  <baynes@ukpsshp1.serigate.philips.nl> wrote:
  15. >Michael J Zehr (tada@athena.mit.edu) wrote:
  16.  
  17. [snip]
  18.  
  19. >: This is the main question I'm interested, but as a followup, if these
  20. >: always result in the same output, why is the 'h' modifier defined in the
  21. >: first place?
  22. >
  23. >Probably so you can use the same format string with scanf.
  24.  
  25. AVOID THIS ASSUMPTION!!!
  26.  
  27. It's a common trap, and fails with floating point numbers.
  28.  
  29. "%f" ==> output a double (*printf)
  30. "%f" ==> input a float (*scanf)
  31.  
  32. IMHO, the format strings *should* have been designed so that
  33. the same one can be used to read back something written, but
  34. this is not the case.  Sorry, they didn't ask me!  :-)
  35.  
  36. Cheers,
  37. Stan.
  38. --
  39. Stan Ryckman  (stanr@tiac.net)
  40.   (Apologies for non-responses or late responses to some posts;
  41.   .newsrc was trashed and I'm trying to get it back to where it was.)
  42.